package biolabs.mcl

abstract class AnalysisResult[+T] {
	val successful: Boolean
	def getResult(): T
	def getErrorMessage(): String
}

case class AnalysisSuccess[T](result: T) extends AnalysisResult[T] {
	override val successful = true
	override def getResult() = result
	override def getErrorMessage() = throw new NoSuchElementException("AnalysisSuccess.getErrorMessage()")
}

case class AnalysisError[T](msg: String) extends AnalysisResult[T] {
	override val successful = false
	override def getResult() = throw new NoSuchElementException("AnalysisError.getResult()")
	override def getErrorMessage() = msg

	def cast[U](): AnalysisError[U] = AnalysisError(msg)
}